home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectShow / DMO / GargleDMO / MedParamBase / param.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-08  |  5.2 KB  |  113 lines

  1. //------------------------------------------------------------------------------
  2. // File: Param.h
  3. //
  4. // Desc: DirectShow sample code - definitions of CCurveItem, CCurveList,
  5. //       and CParamsManager classes.
  6. //
  7. // Copyright (c) 1999-2001 Microsoft Corporation.  All rights reserved.
  8. //------------------------------------------------------------------------------
  9.  
  10. #ifndef __TOOLPARAM_H__
  11. #define __TOOLPARAM_H__
  12.  
  13.  
  14.  
  15. #include "medparam.h"
  16. #include "alist.h"
  17.  
  18. typedef struct _ParamInfo
  19. {
  20.     DWORD dwIndex;                      // Which parameter.
  21.     MP_PARAMINFO    MParamInfo;         // Standard MediaParams structure.
  22.     WCHAR *         pwchText;           // Array of text names for enumerated types.
  23. } ParamInfo;
  24.  
  25. class CCurveItem : public AListItem
  26. {
  27. public:
  28.     CCurveItem* GetNext() { return (CCurveItem*)AListItem::GetNext();}
  29.     MP_ENVELOPE_SEGMENT m_Envelope;     // Envelope segment.
  30. };
  31.  
  32. class CCurveList : public AList
  33. {
  34. public:
  35. //    void Clear();
  36.     void AddHead(CCurveItem* pCurveItem) { AList::AddHead((AListItem*)pCurveItem);}
  37. //    void Insert(CCurveItem* pCurveItem);
  38.     CCurveItem* GetHead(){return (CCurveItem*)AList::GetHead();}
  39. //    CCurveItem* GetItem(LONG lIndex){return (CCurveItem*)AList::GetItem(lIndex);}
  40.     CCurveItem* RemoveHead(){ return (CCurveItem*)AList::RemoveHead();}
  41. //    void Remove(CCurveItem* pCurveItem){AList::Remove((AListItem*)pCurveItem);}
  42. //    void AddTail(CCurveItem* pCurveItem){AList::AddTail((AListItem*)pCurveItem);}
  43. //    CCurveItem* GetTail(){ return (CCurveItem*)AList::GetTail();}
  44.     ~CCurveList();
  45. };
  46.  
  47. #define MAX_REF_TIME    0x7FFFFFFFFFFFFFFF
  48. #define MP_CAPS_ALL     MP_CAPS_CURVE_JUMP | MP_CAPS_CURVE_LINEAR | MP_CAPS_CURVE_SQUARE | MP_CAPS_CURVE_INVSQUARE | MP_CAPS_CURVE_SINE
  49.  
  50. class CParamsManager :  public IMediaParams, public IMediaParamInfo
  51. {
  52. public:
  53.     CParamsManager();
  54.     ~CParamsManager();
  55.  
  56.     // IUnknown
  57.     STDMETHOD(QueryInterface)(REFIID, LPVOID FAR *) PURE;
  58.     STDMETHOD_(ULONG, AddRef)() PURE;
  59.     STDMETHOD_(ULONG, Release)() PURE;
  60.  
  61.     // IMediaParams
  62.     STDMETHODIMP GetParam(DWORD dwParamIndex, MP_DATA *pValue);
  63.     STDMETHODIMP SetParam(DWORD dwParamIndex,MP_DATA value);
  64.     STDMETHODIMP AddEnvelope(DWORD dwParamIndex,DWORD cPoints,MP_ENVELOPE_SEGMENT *ppEnvelope);
  65.     STDMETHODIMP FlushEnvelope( DWORD dwParamIndex,REFERENCE_TIME refTimeStart,REFERENCE_TIME refTimeEnd);
  66.     STDMETHODIMP SetTimeFormat( GUID guidTimeFormat,MP_TIMEDATA mpTimeData);
  67.  
  68.     // IMediaParamInfo
  69.     STDMETHODIMP GetParamCount(DWORD *pdwParams);
  70.     STDMETHODIMP GetParamInfo(DWORD dwParamIndex,MP_PARAMINFO *pInfo);
  71.     STDMETHODIMP GetParamText(DWORD dwParamIndex,WCHAR **ppwchText);
  72.     STDMETHODIMP GetNumTimeFormats(DWORD *pdwNumTimeFormats);
  73.     STDMETHODIMP GetSupportedTimeFormat(DWORD dwFormatIndex,GUID *pguidTimeFormat);        
  74.     STDMETHODIMP GetCurrentTimeFormat( GUID *pguidTimeFormat,MP_TIMEDATA *pTimeData);
  75.  
  76.     // other (non-COM) functions
  77.     HRESULT InitParams(DWORD cTimeFormats, const GUID *pguidTimeFormats, DWORD dwFormatIndex, MP_TIMEDATA mptdTimeData, DWORD cParams, ParamInfo *pParamInfos);
  78.     HRESULT GetParamFloat(DWORD dwParamIndex,REFERENCE_TIME rtTime,float *pval); // returns S_FALSE if rtTime is after the end time of the last curve
  79.     HRESULT GetParamInt (DWORD dwParamIndex,REFERENCE_TIME rt,long *pval); // returns S_FALSE if rtTime is after the end time of the last curve
  80.     HRESULT CopyParamsFromSource(CParamsManager * pSource);
  81.  
  82.     // parameter control curve handling
  83.     class UpdateCallback
  84.     {
  85.     public:
  86.         // Define this in derived classes if you are going to use UpdateActiveParams.
  87.         //  Called by CParamsManager inside UpdateActiveParams to update the effect's internal state variables.
  88.         //  SetParamUpdate should be the same as SetParam, except that DMO defer the call to the base class
  89.         //  (CParamsManager::SetParam) in SetParam but should not do so in SetParamUpdate.
  90.         virtual HRESULT SetParamUpdate(DWORD dwParamIndex, MP_DATA value) = 0;
  91.     };
  92.     // function that calls SetParam to adjust the value of all parameters that may have changed to their
  93.     // new values at time rtTime
  94.     void UpdateActiveParams(REFERENCE_TIME rtTime, UpdateCallback &rThis); // rThis should be the derived class (*this)
  95.     DWORD GetActiveParamBits() { return m_dwActiveBits; }
  96.  
  97. protected:
  98.     // data
  99.  
  100.     CRITICAL_SECTION m_ParamsCriticalSection;
  101.     BOOL            m_fDirty;                    // Has data changed since last file load or save?
  102.     DWORD           m_cTimeFormats;             // Number of supported time formats.
  103.     GUID            *m_pguidTimeFormats;        // Array of supported time formats.
  104.     GUID            m_guidCurrentTimeFormat;    // The time format we're set to.
  105.     MP_TIMEDATA     m_mptdCurrentTimeData;        // The unit of measure for the current time format.
  106.     DWORD           m_cParams;                  // Number of parameters.
  107.     ParamInfo       *m_pParamInfos;             // Array of ParamInfo structures, one for each parameter.
  108.     CCurveList      *m_pCurveLists;             // Array of Curve lists, one for each parameter.
  109.     DWORD           m_dwActiveBits;             // Tracks the params that currently have curves active.
  110. };
  111.  
  112. #endif // __TOOLPARAM_H__
  113.